﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.GateUI {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import com.greensock.*;
    import flash.filters.*;
    import Display.*;
    import Display.aswingui.*;
    import com.greensock.easing.*;

    public class AskFriendsDialog extends GenericDialog {

        public static const TITLE_FONT:ASFont = ASwingHelper.getBoldFont(24);
        public static const TEXT_FONT:ASFont = ASwingHelper.getStandardFont(18);
        public static const BUTTON_FONT:ASFont = ASwingHelper.getBoldFont(14);
        public static const TEXT_COLOR:uint = 9463372;
        public static const TITLE_COLOR:uint = 0xFFFFFF;
        public static const GLOW_FILTER:GlowFilter = new GlowFilter(489375, 1, 5, 5, 4, 2);
        public static const REQUEST_BUILDABLE:String = "request";
        public static const FEED_BUILDABLE:String = "feed";

        public static var assets:Dictionary;

        private var m_item:Item;
        private var m_building:Item;
        private var m_iconAsset:DisplayObject;
        private var m_viralType:String;

        public function AskFriendsDialog(_arg1:Item, _arg2:DisplayObject, _arg3:Item, _arg4:String="request"){
            this.m_item = _arg1;
            this.m_building = _arg3;
            m_message = ZLoc.t("Dialogs", "askDialog_body");
            m_title = ZLoc.t("Dialogs", "askDialog_title", {item:this.m_item.localizedName});
            this.m_viralType = _arg4;
            super(m_message, "", GenericDialogView.TYPE_SHARECANCEL, this.onAsk, m_title, this.m_item.icon, true, 0, "", this.onSkip);
        }
        override protected function onAssetsLoaded(_arg1:Event=null):void{
            assets = new Dictionary();
            assets["dialog_bg"] = (new m_comObject.dialog_bg() as DisplayObject);
            m_jpanel = new AskFriendsDialogView(assets, m_message, m_title, GenericDialogView.TYPE_ASKFRIEND, m_callback, this.m_item.icon, 0, m_SkipCallback);
            finalizeAndShow();
        }
        override protected function showTween():void{
            var startSize:* = null;
            var matParams:* = null;
            var mat:* = null;
            this.mouseEnabled = (this.mouseChildren = false);
            startSize = new Point(m_content.width, m_content.height);
            matParams = {scale:0.01};
            if (m_centered){
                centerPopup();
            };
            mat = new Matrix();
            mat.translate((-(startSize.x) / 2), (-(startSize.y) / 2));
            mat.scale(matParams.scale, matParams.scale);
            mat.translate((startSize.x / 2), (startSize.y / 2));
            m_content.transform.matrix = mat;
            TweenLite.to(matParams, TWEEN_TIME, {
                scale:1,
                ease:Back.easeOut,
                onUpdate:function ():void{
                    mat = new Matrix();
                    mat.translate((-(startSize.x) / 2), (-(startSize.y) / 2));
                    mat.scale(matParams.scale, matParams.scale);
                    mat.translate((startSize.x / 2), (startSize.y / 2));
                    m_content.transform.matrix = mat;
                    if (m_centered){
                        centerPopup();
                    };
                    this.visible = true;
                },
                onComplete:function ():void{
                    onShowComplete();
                }
            });
        }
        public function onSkip(_arg1:GenericPopupEvent):void{
            closeMe(_arg1);
        }
        public function onAsk(_arg1:GenericPopupEvent):void{
            var _local2:Boolean;
            var _local3:String;
            var _local4:GenericDialog;
            if (_arg1.button == GenericDialogView.YES){
                closeMe(_arg1);
                if (this.m_viralType == REQUEST_BUILDABLE){
                    _local2 = Global.world.viralMgr.sendMunicipalMaterialRequest(Global.player, this.m_building.localizedName, this.m_item);
                } else {
                    if (this.m_viralType == FEED_BUILDABLE){
                        _local2 = Global.world.viralMgr.sendMunicipalMaterialFeed(Global.player, this.m_building.localizedName, this.m_item);
                    };
                };
                if (!_local2){
                    _local3 = ZLoc.t("Dialogs", "MunicipalThrottlingMessage");
                    _local4 = new GenericDialog(_local3);
                    UI.displayPopup(_local4);
                };
            } else {
                this.onSkip(_arg1);
            };
        }

    }
}//package Display.GateUI 
